﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script src="http://www.jellyfish.com/javascripts/prototype.js?1177444569" type="text/javascript"></script>
<script src="http://www.jellyfish.com/javascripts/effects.js?1177444569" type="text/javascript"></script>
<script src="http://www.jellyfish.com/javascripts/dragdrop.js?1177444569" type="text/javascript"></script>
<script src="http://www.jellyfish.com/javascripts/controls.js?1177444569" type="text/javascript"></script>

<script src="http://www.jellyfish.com/javascripts/application.js?1177444569" type="text/javascript"></script>
	
<script src="http://www.jellyfish.com/javascripts/json.js?1187875092" type="text/javascript"></script>

<link href="http://www.jellyfish.com/shoppers/stylesheets/shoppers.css?1189522426" media="screen" rel="Stylesheet" type="text/css" />
<link href="http://www.jellyfish.com/shoppers/stylesheets/buttons.css?1178554672" media="screen" rel="Stylesheet" type="text/css" />

<title>SwakSmack Message</title>
<script language="javascript">

var MAX_TRY_ATTEMPTS = 50;
var curAttempt = 0;


function submitForm() {

document.getElementById('msg_window').style.visibility = 'hidden';
document.getElementById('msg_sending').style.visibility = 'visible';

var myRequest = new Ajax.Request('http://www.jellyfish.com/shoppers/me/send_message', 
{
asynchronous:true, 
evalScripts:true, 
parameters:Form.serialize(document.getElementById('sendPrivateMessageForm')),


onComplete: function(transport) {

    if (200 == transport.status){
         setTimeout(function () {
                     window.close(); 
                   }, 500);
      
  }
   else {
        document.getElementById('msg_sent_error').style.visibility = 'visible';
   }
}
}
);

}

// the purpose of this method is to make sure the form has required element values before displaying.
function waitForData() { // need to add somesort of giveup here so this thing does not recurese for ever
    var username = document.getElementById('userName').innerHTML;
    var euid = document.getElementById('euid').value;
    var r_euid = document.getElementById('receiver_euid').value;
   
    if (username=='' || r_euid=='' || euid=='') {
    curAttempt++;
        if (curAttempt>MAX_TRY_ATTEMPTS) {
        document.getElementById('load_wait').style.visibility = 'hidden';
        document.getElementById('load_error').style.visibility = 'visible';
      return;
    }
     setTimeout(function () {
                     waitForData();
                   }, 500);

    } else{
        //alert('visible');
        document.getElementById('load_wait').style.visibility = 'hidden';
        document.getElementById('msg_window').style.visibility = 'visible';
    }
    
}

</script>
<style>
.msgTxt { 
	font-size:14px;
	color:#ffffff;
	font-weight:normal;
}
</style>
</head>
<body onload="waitForData();">


<div align="center" id="msg_sending" style="visibility:hidden; position:absolute" class="msgTxt">
<strong>Sending...Please wait...</strong>
</div>


<div align="center" id="msg_sent_error" style="visibility:hidden; position:absolute" class="msgTxt">
<strong>There was an error sending the message.</strong>

<table border=0 cellpadding=0 cellpadding=0>
<tr>
<td><a href="#" onclick="window.close();" id="A1">Pleas try again later.</a></td>
<td><a href="#" onclick="window.close();" id="close_link" class="delete_message"></a></td></tr>
</table>
</div>


<div align="center" id="load_error" style="visibility:hidden; position:absolute" class="msgTxt">
<strong>There was an error initializing the message window.</strong>
<div id="error_buttons"><a href="#" onclick="window.close();" style="vertical-align: middle;" class="cancel" id="cancel_error" ></a></div>

</div>
<div align="center" id="load_wait" style="visibility:visible; position:absolute" class="msgTxt">
<strong>Loading...Please wait...</strong>
</div>

<div align="center" id="msg_window" style="visibility:hidden; position:absolute;"  class="msgTxt">

<form action="http://www.jellyfish.com/shoppers/me/send_message" id="sendPrivateMessageForm" method="post" >                        
Send <strong><span id="userName"></span></strong> a private message<br/>
    <input id="euid" name="euid" type="hidden" value="" />
    <input id="receiver_euid" name="receiver_euid" type="hidden" value="" />
    <input id="friend_request" name="friend_request" type="hidden" value="" />

    
    <textarea id="messageBody" name="messageBody" style="width: 290px; height: 200px;"></textarea>
   
<table border=0 cellpadding=0 cellspacing=0>
<tr><td><a href="#" id="send_message" value="Send Message" style="vertical-align: middle;" class="send" onclick="submitForm()"></a></td>
<td><a href="#" onclick="window.close();" style="vertical-align: middle;" class="cancel" id="cancel_send_message"></a></td></tr>
</table>


                         
    
    </form>
</div>
</body>
</html>